import java.lang.Math;
import java.io.*;

public class CulcYoshi {
	//#1
	public static float Addition(float x,float y){
		return x + y;
	}
	
	//#2
	public static float Subtraction(float x, float y){
		return x-y;
	}

	//#3
	public static float multiplication(float x,float y){
		return x*y;
	}
	
	//#4
	public static float division(float x,float y)
	{
		if(y == 0){
			System.out.println("Zero Divide!");
			return 0;
		}
		return x/y;
	}
	
	//#5
	public static float AreaOfCircle(float r){
		return r * r * (float)Math.PI;
	}
	
	//#6
	public static float AreaOfRectangle(float x,float y){
		return x * y;
	}
	
	//#7
	public static float circumference(float r)
	{
		return 2*r*(float)Math.PI;
	}
	
	//#8
	public static float PerimeterOfRectangle(float x,float y){
		return 2 * (x + y);
	}
	
	//#9
	public static float AreaOfSquare(float x){
		return x *x ;
	}
	
	//#10
	public static float PerimeterOfSquare(float x){
		return 4 * x;
	}
	
	//#11
	public static float Cos(float x){
		return (float)Math.cos(Math.toDegrees((float)x));
	}
	
	//#12
	public static float Sin(float x){
		return (float)Math.sin(Math.toDegrees((float)x));
	}

	//#13
	public static float Tan(float x){
		return (float)Math.tan(Math.toDegrees((float)x));
	}
	
	//#14
	public static float AreaOfTriangle(float x,float y){
		return x * y /2;
	}
	
	//#15
	public static void readWriteFile(String filePath) throws IOException{
		double result = 0;
		//String everything;
		BufferedReader br = new BufferedReader(new FileReader(filePath));
		BufferedWriter bw = new BufferedWriter(new FileWriter ("/Users/Mohammad/Desktop/Result.txt"));
		    try {
		        //StringBuilder sb = new StringBuilder();
		        String line = br.readLine();

		        while (line != null) {
		        bw.write(line + "\n");
		        String[] parts = line.split(" ");
		        String part1 = parts[0];
		        String part2 = parts[1];
		        String part3 = null;
		        if(parts.length == 2)
		        part3 = parts[2];
		        if(part1.equals("rect"))
		        {
		        result = PerimeterOfRectangle(Float.parseFloat(part2), Float.parseFloat(part3));
		        }
		        else
		        if(part1.equals("tria")){
		        result = AreaOfTriangle(Float.parseFloat(part2), Float.parseFloat(part3));
		        }
		        else
		        if(part1.equals("circ")){
		        result = circumference(Float.parseFloat(part2));
		        }
		        else{
		        System.out.println("ERRRRROOOORRRRR!");
		        System.exit(1);
		        }
		        bw.write("Result = " + result + " \n");
		            //sb.append(line);
		            //sb.append("\n");
		            line = br.readLine();
		        }
		        //everything = sb.toString();
		    } finally {
		        br.close();
		        bw.close();
		    }
		//return everything;
		}
}
